package com.zh.work.service.platform.trans.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.zh.work.dao.platform.trans.QuickTransTodayMapper;
import com.zh.work.entity.trans.QuickTransTodayEntity;
import com.zh.work.service.platform.trans.QuickTransTodayService;
import org.apache.commons.lang3.ObjectUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Objects;

/**
 * code is far away from bug with the animal protecting
 * ┏┓　　　┏┓
 * ┏┛┻━━━┛┻┓
 * ┃　　　　　　　┃
 * ┃　　　━　　　┃
 * ┃　┳┛　┗┳　┃
 * ┃　　　　　　　┃
 * ┃　　　┻　　　┃
 * ┃　　　　　　　┃
 * ┗━┓　　　┏━┛
 * 　　┃　　　┃神兽保佑
 * 　　┃　　　┃代码无BUG！
 * 　　┃　　　┗━━━┓
 * 　　┃　　　　　　　┣┓
 * 　　┃　　　　　　　┏┛
 * 　　┗┓┓┏━┳┓┏┛
 * 　　　┃┫┫　┃┫┫
 * 　　　┗┻┛　┗┻┛
 *
 * @Description: 快捷交易数据业务实现层
 * @Author: Li.HuiNeng
 * @Create in: 2020-01-07 14:18
 * @Version: 1.0.1
 */
@Service
public class QuickTransTodayServiceImpl extends ServiceImpl<QuickTransTodayMapper, QuickTransTodayEntity> implements QuickTransTodayService {

    @Autowired
    private QuickTransTodayMapper mapper;


    @Override
    public IPage<QuickTransTodayEntity> getQuickTransTodayPages(Page<QuickTransTodayEntity> page, QuickTransTodayEntity param) {
        return mapper.selectPage(page, new LambdaQueryWrapper<QuickTransTodayEntity>()
                .between(ObjectUtils.allNotNull(param.getStartDateTime(), param.getEndDateTime()), QuickTransTodayEntity::getTransDate,
                        param.getStartDateTime(), param.getEndDateTime())
                .between(ObjectUtils.allNotNull(param.getStartTime(), param.getEndTime()), QuickTransTodayEntity::getTransTime,
                        param.getStartTime(), param.getEndTime())
                .between(ObjectUtils.allNotNull(param.getAmtBegin(), param.getAmtEnd()), QuickTransTodayEntity::getAmount,
                        param.getAmtBegin(), param.getAmtEnd())
                .eq(StringUtils.isNotEmpty(param.getAgentNo()), QuickTransTodayEntity::getAgentNo, param.getAgentNo())
                .eq(StringUtils.isNotEmpty(param.getChannelCode()), QuickTransTodayEntity::getChannelCode, param.getChannelCode())
                .eq(StringUtils.isNotEmpty(param.getBranchNo()), QuickTransTodayEntity::getBranchNo, param.getBranchNo())
                .eq(Objects.nonNull(param.getStatus()), QuickTransTodayEntity::getStatus, param.getStatus())
                .like(StringUtils.isNotEmpty(param.getMerchOrderNo()), QuickTransTodayEntity::getMerchOrderNo, param.getMerchOrderNo())
                .like(StringUtils.isNotEmpty(param.getMerchNo()), QuickTransTodayEntity::getMerchNo, param.getMerchNo())
                .like(StringUtils.isNotEmpty(param.getSystemOrderNo()), QuickTransTodayEntity::getSystemOrderNo, param.getSystemOrderNo())
        );
    }
}
